/*
 * Copyright (c) 2017, www.zm0618.com All Rights Reserved..
 */

package com.light.hessian.consul.util;

import com.ecwid.consul.v1.ConsulClient;
import org.apache.commons.lang3.StringUtils;

/**
 * Created by zhaojun on 2017/02/18.
 */
public class ConsulClientUtils {

    public static ConsulClient  createClient(String node){
        node=StringUtils.trim(node);
        if (StringUtils.isBlank(node)){
            return new ConsulClient();
        }
        int sindex=-1;
        if ((sindex=node.indexOf(":"))>0){
            String host=node.substring(0,sindex);
            String port=node.substring(sindex+1);
            return new ConsulClient(host,Integer.parseInt(port));
        }else{
            return new ConsulClient(node);
        }
    }
}
